using System;
using System.Collections;
namespace Circus.CodeEditor.TextSource
{
	public class HyperText
	{
		private static Hashtable identsTable;
		private static void InitIdentsTable()
		{
			if (HyperText.identsTable == null)
			{
				HyperText.identsTable = new Hashtable();
				for (char c = 'A'; c <= 'Z'; c += '\u0001')
				{
					HyperText.identsTable.Add(c, c);
				}
				for (char c = 'a'; c <= 'z'; c += '\u0001')
				{
					HyperText.identsTable.Add(c, c);
				}
				for (char c = '0'; c <= '9'; c += '\u0001')
				{
					HyperText.identsTable.Add(c, c);
				}
				HyperText.identsTable.Add('_', '_');
			}
		}
		public static bool IsEmailString(string text)
		{
			bool flag = string.Compare(text, 0, EditConsts.MailTo, 0, EditConsts.MailTo.Length, true) == 0;
			if (!flag)
			{
				int length = text.Length;
				int num = text.IndexOf("@");
				int num2 = text.LastIndexOf("@");
				int num3 = text.LastIndexOf(".");
				flag = (num >= 0 && num == num2 && num3 > num && num != length - 1);
				if (flag)
				{
					HyperText.InitIdentsTable();
					flag = HyperText.identsTable.ContainsKey(text[num]);
				}
			}
			return flag;
		}
		public static bool IsWWWString(string text)
		{
			return string.Compare(text, 0, EditConsts.WWW, 0, EditConsts.WWW.Length, true) == 0;
		}
		public static bool IsHttpString(string text)
		{
			return string.Compare(text, 0, EditConsts.HTTPProtocol, 0, EditConsts.HTTPProtocol.Length, true) == 0;
		}
		public static bool IsHttpsString(string text)
		{
			return string.Compare(text, 0, EditConsts.HTTPSProtocol, 0, EditConsts.HTTPSProtocol.Length, true) == 0;
		}
		public static bool IsFtpString(string text)
		{
			return string.Compare(text, 0, EditConsts.FTPProtocol, 0, EditConsts.FTPProtocol.Length, true) == 0;
		}
		public static bool IsGopherString(string text)
		{
			return string.Compare(text, 0, EditConsts.GopherProtocol, 0, EditConsts.GopherProtocol.Length, true) == 0;
		}
		public static bool IsFileString(string text)
		{
			return string.Compare(text, 0, EditConsts.FileProtocol, 0, EditConsts.FileProtocol.Length, true) == 0;
		}
		public static bool IsHyperText(string text)
		{
			return HyperText.IsEmailString(text) || HyperText.IsWWWString(text) || HyperText.IsHttpString(text) || HyperText.IsHttpsString(text) || HyperText.IsFtpString(text) || HyperText.IsGopherString(text) || HyperText.IsFileString(text);
		}
	}
}
